package String_process;

import java.util.Scanner;

/**
 * @author dx
 * @version 1.0
 * @date 2022/5/11 16:26
 * @description:
 */
public class ReverseSentense2 {
    public static void main(String[] args) {
        Scanner sr = new Scanner(System.in);
        String s = sr.nextLine();
        Scanner sr2 = new Scanner(System.in);
        int n = sr2.nextInt();
        System.out.println(new Resen2_solution().reverseLeftWords(s,n));
    }

}

class Resen2_solution{
    public String reverseLeftWords(String s,int n){
        int len = s.length();
        char [] x1 = new char[n];
        char [] x2 = new char[len-n];
        int i;
        for(i = 0;i< n;i++){
            x1 [i] = s.charAt(i);
        }
        for(int j = 0;j<len-n;j++){
            x2[j] = s.charAt(i++);
        }
        String ret2 = new String(x2,0,len-n);
        String ret1 = new String(x1,0,n);
        return ret2+ret1;

    }
//    public String Rever(String s){
//
//        int len = s.length();
//        char [] ans = new char[len];
//        int j = 0;
//        int i = len-1;
//        while (len>=0){
//            ans[j++] = s.charAt(i--);
//        }
//        String ret = new String(ans,0,len);
//        return ret;
//    }
}
